package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Favorite;
import com.aaa.ssm.service.FavoriteService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/favorite")
public class FavoriteController extends BaseController{
    //依赖注入
    @Resource
    private FavoriteService favoriteService;
    /**
     * 分页带参查询
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Favorite> page){
        return success(favoriteService.queryPage(page));
    }
    /**
     * 根据编号查询
     */
    @PostMapping("queryById")
    public Result queryById(String id){
        return success(favoriteService.queryById(id));
    }
    /**
     * 添加
     */
    @PostMapping("add")
    public Result add(@RequestBody Favorite favorite){
        return success(favoriteService.add(favorite));
    }
    /**
     * 更新
     */
    @PostMapping("update")
    public Result update(@RequestBody Favorite favorite){
        return success(favoriteService.update(favorite));
    }
    /**
     * 编号删除
     */
    @DeleteMapping("delete/{id}")
    public Result delete( @PathVariable("id") String id){
        return success(favoriteService.deleteById(id));
    }
}
